package com.carrental.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.carrental.service.UserService;

/**
 * Servlet implementation class UserDeleteSerlvet
 */
@WebServlet("/UserDeleteSerlvet")
public class UserDeleteSerlvet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	UserService userService;
       
    /**
     * @throws Exception 
     * @see HttpServlet#HttpServlet()
     */
    public UserDeleteSerlvet() throws Exception {
        super();
        userService = new UserService();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String username = request.getParameter("username");
		try {
			userService.delete(username);
			response.sendRedirect("adminUserList.jsp");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
